import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule, Http, XHRBackend, RequestOptions } from '@angular/http';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';

import { AboutPage } from '../pages/about/about';
import { UserPage } from '../pages/user/user';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';

import { LoginPage } from '../pages/login/login';

import { RegPage } from '../pages/reg/reg';
import { FriendPage } from '../pages/friend/friend';
import { FriendInfoPage } from '../pages/friend-info/friend-info';

import { ChatRoomPage } from '../pages/chat-room/chat-room';
import { AddFriendPage } from '../pages/add-friend/add-friend';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { PagesLoginLoginProvider } from '../providers/pages-login-login/pages-login-login';


// providers
import { AppSetting } from '../providers/app.seting';
import { Utils } from '../providers/utils';
import { InterceptedHttp } from '../providers/http.interceptor';

// 
import { ComponentsModule } from '../components/components.module';

import { SocketIoModule, SocketIoConfig } from 'ng-socket-io';
const config: SocketIoConfig = { url: 'http://localhost:3000', options: {} };
@NgModule({
  declarations: [
    MyApp,
    AboutPage,
    UserPage,
    HomePage,
    TabsPage,
    LoginPage,
    RegPage,
    ChatRoomPage,
    AddFriendPage,
    FriendPage,
    FriendInfoPage
    
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    IonicModule.forRoot(MyApp),
    SocketIoModule.forRoot(config),
    ComponentsModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    AboutPage,
    UserPage,
    HomePage,
    TabsPage,
    LoginPage,
    RegPage,
    ChatRoomPage,
    AddFriendPage,
    FriendPage,
    FriendInfoPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {
      provide: Http,
      useFactory: (xhrBackend, requestOptions) => {
        return new InterceptedHttp(xhrBackend, requestOptions);
      },
      deps: [XHRBackend, RequestOptions]
    },
    { provide: ErrorHandler, useClass: IonicErrorHandler },
    Utils,
    AppSetting
  ]
})
export class AppModule { }
